"""
智谱大语言模型 ChatGLM
验证模型的API-KEY是否可用

pip install zhipuai
"""
from zhipuai import ZhipuAI

client = ZhipuAI(api_key="5cb30e8c06424694911e62083e9a614a.iWZjHkiDSpzCcscX")

# 用户user问题
# messages = [{
#     "role": "user",
#     "content": "中国的首都是哪里"
# }]

messages = [{"role": "system", "content": "请将下列的语句翻译成英文"},
            {"role": "user", "content": "中国的首都是哪里"}]

response = client.chat.completions.create(
    model="glm-4-plus",  # 模型名称 参考：https://open.bigmodel.cn/console/modelcenter/square
    messages=messages
)
print(response.choices[0].message)